package com.credithc.eagleeye.plugins.util;
/**
 * 描 述: <br/>
 * 作 者: zhangjin<br/>
 * 创 建：2019年10月21日<br/>
 * 版 本：v1.0.0<br>
 * <p>
 * 历 史: (版本) 作者 时间 注释 <br/>
 */
public class ClassUtil {
    /**
     * 判断是否是web环境
     */
    public static boolean servletPresent = false;
    /**
     * 判断是否是springMvc环境
     */
    public static boolean springWebPresent = false;
    /**
     * 获取RabbitMq不通版本的CorrelationDataClass
     */
    public static Class rabbitCorrelationDataClass = null;
    public static boolean ribbonPresent = false;
    public static boolean webServiceCXFPresent = false;
    static {
        try {
            servletPresent = null != Class.forName("javax.servlet.ServletRequest");
        } catch (Throwable t) {
            servletPresent = false;
        }
        try {
            springWebPresent = null != Class.forName("org.springframework.web.context.request.RequestContextHolder");
        } catch (Throwable t) {
            springWebPresent = false;
        }
        try {
            rabbitCorrelationDataClass = Class.forName("org.springframework.amqp.rabbit.connection.CorrelationData");
        } catch (Throwable t) {
        }
        if (rabbitCorrelationDataClass == null) {
            try {
                rabbitCorrelationDataClass = Class.forName("org.springframework.amqp.rabbit.support.CorrelationData");
            } catch (Throwable t) {
            }
        }
        try {
            if (null != Class.forName("org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient") && null != Class.forName("org.springframework.cloud.netflix.ribbon.SpringClientFactory")) {
                ribbonPresent = true;
            }
        } catch (Throwable t) {
            ribbonPresent = false;
        }


        try {
            webServiceCXFPresent = null != Class.forName("org.apache.cxf.phase.PhaseInterceptorChain");
        } catch (Throwable t) {
            webServiceCXFPresent = false;
        }

    }
}
